<template>
  <a-modal v-model="visible" :width="1080" title="选择供应商管理" @ok="batchSelectItem">
    <!-- 查询区域 -->
    <!--<div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>-->
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>

      <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:selectionType}" class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="55px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a v-if="selectionType=='radio'" @click="selectItem(record)">选择</a>
        </span>

      </a-table>
    </div>

  </a-modal>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/MyJeecgListMixin'


export default {
  name: 'SmsSupplierList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
  },
  data () {
    return {
      pageCheckedKeys: [],
      noPageCheckedKeys: [],
      pageCheckedRows: [],
      noPageCheckedRows: [],
      visible: false,
      description: '供应商管理管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '店铺id',
          align: "center",
          dataIndex: 'shopId'
        },
        {
          title: '商铺名称',
          align: "center",
          dataIndex: 'name'
        },
        {
          title: '商铺logo',
          align: "center",
          dataIndex: 'logoUrl'
        },
        {
          title: '商铺简介(预留)',
          align: "center",
          dataIndex: 'remark'
        },
        {
          title: '排序',
          align: "center",
          dataIndex: 'sort'
        },
        {
          title: '店铺详情（富文本方式）',
          align: "center",
          dataIndex: 'richText'
        },
        {
          title: '负责人姓名',
          align: "center",
          dataIndex: 'ownerName'
        },
        {
          title: '商铺电话',
          align: "center",
          dataIndex: 'ownerTel'
        },
        {
          title: '商铺接收发货电话',
          align: "center",
          dataIndex: 'shopRemindTel'
        },
        {
          title: 'createTime',
          align: "center",
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: 'updateTime',
          align: "center",
          dataIndex: 'updateTime',
          customRender: function (text) {
            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '冻结金额',
          align: "center",
          dataIndex: 'freeze'
        },
        {
          title: '历史总额',
          align: "center",
          dataIndex: 'historyBalance'
        },
        {
          title: '可用余额',
          align: "center",
          dataIndex: 'balance'
        },
        {
          title: '是否可用 0：否  1：是',
          align: "center",
          dataIndex: 'status'
        },
        {
          title: '是否删除',
          align: "center",
          dataIndex: 'delFlag'
        },
        {
          title: '提现手续费比例',
          align: "center",
          dataIndex: 'cashDiscount'
        },
        {
          title: '是否推荐  1 不推荐  2推荐(预留)',
          align: "center",
          dataIndex: 'isRecommend'
        },
        {
          title: '商铺展示图片(预留)',
          align: "center",
          dataIndex: 'imgUrl'
        },
        {
          title: '一级经营类目',
          align: "center",
          dataIndex: 'categoryId'
        },
        {
          title: '二维码(预留)',
          align: "center",
          dataIndex: 'qrcode'
        },
        {
          title: '省主键',
          align: "center",
          dataIndex: 'pId'
        },
        {
          title: '市主键',
          align: "center",
          dataIndex: 'cId'
        },
        {
          title: '区主键',
          align: "center",
          dataIndex: 'dId'
        },
        {
          title: '详细地址',
          align: "center",
          dataIndex: 'address'
        },
        {
          title: '地址明细',
          align: "center",
          dataIndex: 'fullAddress'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/mallBase/smsSupplier/list",
        delete: "/mallBase/smsSupplier/delete",
        deleteBatch: "/mallBase/smsSupplier/deleteBatch",
        exportXlsUrl: "/mallBase/smsSupplier/exportXls",
        importExcelUrl: "mallBase/smsSupplier/importExcel",

      },
      dictOptions: {},
    }
  },
  created () {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    open () {
      this.loadData()
    },
    setSelected () {
      this.pageCheckedKeys = []
      this.noPageCheckedKeys = []
      this.pageCheckedRows = []
      this.noPageCheckedRows = []
      for (let i = 0; i < this.checkedKeys.length; i++) {
        let isSelect = false
        for (let j = 0; j < this.dataSource.length; j++) {
          if (this.dataSource[j].id == this.checkedKeys[i]) {
            isSelect = true
          }
        }
        if (isSelect) {
          this.pageCheckedKeys.push(this.checkedKeys[i])
          this.pageCheckedRows.push(this.checkedRows[i])
        } else {
          this.noPageCheckedKeys.push(this.checkedKeys[i])
          this.noPageCheckedRows.push(this.checkedRows[i])
        }
      }
      this.selectedRowKeys = this.pageCheckedKeys
    },
    initDictConfig () {
    }
  }
}
        </script>
<style scoped>
@import '~@assets/less/common.less';
</style>
